home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / konq_propsview.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.5 KB  |  186 lines

  1. /*  This file is part of the KDE project
  2.     Copyright (C) 1997 David Faure <faure@kde.org>
  3.  
  4.     This program is free software; you can redistribute it and/or modify
  5.     it under the terms of the GNU General Public License as published by
  6.     the Free Software Foundation; either version 2 of the License, or
  7.     (at your option) any later version.
  8.  
  9.     This program is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.     GNU General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU General Public License
  15.     along with this program; if not, write to the Free Software
  16.     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  17.  
  18. */
  19.  
  20. #ifndef __konq_viewprops_h__
  21. #define __konq_viewprops_h__
  22.  
  23. #include <qpixmap.h>
  24. #include <qstringlist.h>
  25.  
  26. #include <kurl.h>
  27. #include <libkonq_export.h>
  28.  
  29. class KInstance;
  30. class KConfigBase;
  31. class KConfig;
  32.  
  33. /**
  34.  * The class KonqPropsView holds the properties for a Konqueror View
  35.  *
  36.  * Separating them from the view class allows to store the default
  37.  * values (the one read from \<kinstance\>rc) in one instance of this class
  38.  * and to have another instance of this class in each view, storing the
  39.  * current values of the view.
  40.  *
  41.  * The local values can be read from a desktop entry, if any (.directory,
  42.  * bookmark, ...). [ .directory is implemented, bookmark isn't ].
  43.  */
  44. class LIBKONQ_EXPORT KonqPropsView
  45. {
  46. public:
  47.  
  48.   /**
  49.    * Constructs a KonqPropsView instance from an instance config file.
  50.    * defaultProps is a "parent" object. If non null, then this instance
  51.    * is the one used by a view, and its value can differ from the default ones.
  52.    * The instance parameter should be the same for both...
  53.    */
  54.   KonqPropsView( KInstance * instance, KonqPropsView * defaultProps /*= 0L*/ );
  55.  
  56.   /** Destructor */
  57.   virtual ~KonqPropsView();
  58.  
  59.   /**
  60.    * Is this the instance representing default properties ?
  61.    */
  62.   bool isDefaultProperties() const {
  63.       // No parent -> we are the default properties
  64.       return m_defaultProps == 0L;
  65.   }
  66.  
  67.   /**
  68.    * Called when entering a directory
  69.    * Checks for a .directory, read it.
  70.    * Don't do this on the default properties instance
  71.    * Returns TRUE if the settings for the new directories are
  72.    * different from the settings in the old directory.
  73.    */
  74.   bool enterDir( const KURL & dir );
  75.  
  76.   /**
  77.    * Turn on/off saving properties locally
  78.    * Don't do this on the default properties instance
  79.    */
  80.   void setSaveViewPropertiesLocally( bool value );
  81.  
  82.   ///
  83.  
  84.   void setIconSize( int size ); // in pixel, 0 for default
  85.   int iconSize() const { return m_iIconSize; }
  86.  
  87.   void setItemTextPos( int pos ); // QIconView::Bottom or QIconView::Right, currently
  88.   int itemTextPos() const { return m_iItemTextPos; }
  89.  
  90.   void setSortCriterion( const QString &criterion );
  91.   const QString& sortCriterion() const;
  92.  
  93.   void setDirsFirst ( bool first );
  94.   bool isDirsFirst() const;
  95.  
  96.   void setDescending (bool descending);
  97.   bool isDescending() const;
  98.  
  99.   void setShowingDotFiles( bool show );
  100.   bool isShowingDotFiles() const { return m_bShowDot; }
  101.  
  102.   void setCaseInsensitiveSort( bool show );
  103.   bool isCaseInsensitiveSort() const;
  104.  
  105.   void setShowingDirectoryOverlays( bool show );
  106.   bool isShowingDirectoryOverlays() const { return m_bShowDirectoryOverlays; }
  107.  
  108.   void setShowingPreview( const QString &preview, bool show );
  109.   void setShowingPreview( bool show );
  110.   bool isShowingPreview( const QString &preview ) const { return ! m_dontPreview.contains(preview); }
  111.   bool isShowingPreview();
  112.   const QStringList &previewSettings();
  113.  
  114.   void setBgColor( const QColor & color );
  115.   const QColor& bgColor(QWidget * widget) const;
  116.   void setTextColor( const QColor & color );
  117.   const QColor& textColor(QWidget * widget) const;
  118.   void setBgPixmapFile( const QString & file );
  119.   const QString& bgPixmapFile() const { return m_bgPixmapFile; }
  120.  
  121.   // Applies bgcolor, textcolor, pixmap to the @p widget
  122.   void applyColors( QWidget * widget ) const;
  123.  
  124. protected:
  125.  
  126.   QPixmap loadPixmap() const;
  127.  
  128.   // Current config object for _saving_
  129.   KConfigBase * currentConfig();
  130.  
  131.   // Current config object for _saving_ settings related to colors
  132.   KConfigBase * currentColorConfig();
  133.  
  134.   QString currentGroup() const {
  135.       return isDefaultProperties() ? 
  136.           QString::fromLatin1("Settings") : QString::fromLatin1("URL properties");
  137.   }
  138.  
  139. private:
  140.   // The actual properties
  141.  
  142.   int m_iIconSize;
  143.   int m_iItemTextPos;
  144.   bool m_bShowDot;
  145.   bool m_bShowDirectoryOverlays;
  146.   QStringList m_dontPreview;
  147.   QColor m_textColor;
  148.   QColor m_bgColor;
  149.   QString m_bgPixmapFile;
  150.  
  151.   // Path to .directory file, whether it exists or not
  152.   QString dotDirectory;
  153.  
  154.   bool m_bSaveViewPropertiesLocally;
  155.  
  156.   // True if we found a .directory file to read
  157.   bool m_dotDirExists;
  158.  
  159.   // Points to the current .directory file if we are in
  160.   // save-view-properties-locally mode, otherwise to the global config
  161.   // It is set to 0L to mark it as "needs to be constructed".
  162.   // This is to be used for SAVING only.
  163.   // Can be a KConfig or a KSimpleConfig
  164.   KConfigBase * m_currentConfig;
  165.  
  166.   // If this is not a "default properties" instance (but one used by a view)
  167.   // then m_defaultProps points to the "default properties" instance
  168.   // Otherwise it's 0L.
  169.   KonqPropsView * m_defaultProps;
  170.  
  171.   /**
  172.    * Private data for KonqPropsView
  173.    * Implementation in konq_propsview.cc
  174.    */
  175.   struct Private;
  176.  
  177.   Private *d;
  178.  
  179. private:
  180.   KonqPropsView( const KonqPropsView & );
  181.   KonqPropsView();
  182. };
  183.  
  184.  
  185. #endif
  186.